/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/*
 *
 * @author Devair
 */
public class TelaGrafica extends javax.swing.JFrame implements TelaView {

    private File nomeArquivo;

    public TelaGrafica() {
        initComponents();
        setExtendedState(JFrame.MAXIMIZED_BOTH);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        barPrincipal = new javax.swing.JToolBar();
        btnNovo = new javax.swing.JButton();
        btnAbrir = new javax.swing.JButton();
        btnGravar = new javax.swing.JButton();
        btnVerificar = new javax.swing.JButton();
        btnTabelaSimbolos = new javax.swing.JButton();
        btnCodigo = new javax.swing.JButton();
        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtCodigo = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtMensagem = new javax.swing.JTextArea();
        mnuAplicacao = new javax.swing.JMenuBar();
        mnuArquivo = new javax.swing.JMenu();
        mnuNovo = new javax.swing.JMenuItem();
        mnuAbrir = new javax.swing.JMenuItem();
        mnuGravar = new javax.swing.JMenuItem();
        mnuGravarComo = new javax.swing.JMenuItem();
        mnuSair = new javax.swing.JMenuItem();
        mnuCompilador = new javax.swing.JMenu();
        mnuTabelaSimbolos = new javax.swing.JMenuItem();
        mnuCodigo = new javax.swing.JMenuItem();
        mnuVerificar = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("IDE");

        barPrincipal.setRollover(true);

        btnNovo.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/gif_47_037.gif"))); // NOI18N
        btnNovo.setText("Novo");
        btnNovo.setFocusable(false);
        btnNovo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNovo.setMaximumSize(new java.awt.Dimension(60, 70));
        btnNovo.setMinimumSize(new java.awt.Dimension(60, 70));
        btnNovo.setPreferredSize(new java.awt.Dimension(53, 53));
        btnNovo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barPrincipal.add(btnNovo);

        btnAbrir.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        btnAbrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/gif_47_073.gif"))); // NOI18N
        btnAbrir.setText("Abrir");
        btnAbrir.setFocusable(false);
        btnAbrir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAbrir.setMaximumSize(new java.awt.Dimension(60, 70));
        btnAbrir.setMinimumSize(new java.awt.Dimension(60, 70));
        btnAbrir.setPreferredSize(new java.awt.Dimension(53, 53));
        btnAbrir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barPrincipal.add(btnAbrir);

        btnGravar.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        btnGravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/gif_47_095.gif"))); // NOI18N
        btnGravar.setText("Gravar");
        btnGravar.setFocusable(false);
        btnGravar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGravar.setMaximumSize(new java.awt.Dimension(60, 70));
        btnGravar.setMinimumSize(new java.awt.Dimension(60, 70));
        btnGravar.setPreferredSize(new java.awt.Dimension(53, 53));
        btnGravar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barPrincipal.add(btnGravar);

        btnVerificar.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        btnVerificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/gif_47_047.gif"))); // NOI18N
        btnVerificar.setText("Verificar");
        btnVerificar.setFocusable(false);
        btnVerificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnVerificar.setMaximumSize(new java.awt.Dimension(60, 70));
        btnVerificar.setMinimumSize(new java.awt.Dimension(60, 70));
        btnVerificar.setPreferredSize(new java.awt.Dimension(53, 53));
        btnVerificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barPrincipal.add(btnVerificar);

        btnTabelaSimbolos.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        btnTabelaSimbolos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/gif_47_025.gif"))); // NOI18N
        btnTabelaSimbolos.setText("Simbolos");
        btnTabelaSimbolos.setDefaultCapable(false);
        btnTabelaSimbolos.setFocusable(false);
        btnTabelaSimbolos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTabelaSimbolos.setMaximumSize(new java.awt.Dimension(60, 70));
        btnTabelaSimbolos.setMinimumSize(new java.awt.Dimension(60, 70));
        btnTabelaSimbolos.setPreferredSize(new java.awt.Dimension(53, 53));
        btnTabelaSimbolos.setRolloverEnabled(true);
        btnTabelaSimbolos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barPrincipal.add(btnTabelaSimbolos);
        btnTabelaSimbolos.getAccessibleContext().setAccessibleDescription("");
        btnTabelaSimbolos.getAccessibleContext().setAccessibleParent(barPrincipal);

        btnCodigo.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        btnCodigo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/gif_47_041.gif"))); // NOI18N
        btnCodigo.setText("Codigo");
        btnCodigo.setDefaultCapable(false);
        btnCodigo.setFocusable(false);
        btnCodigo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCodigo.setMaximumSize(new java.awt.Dimension(60, 70));
        btnCodigo.setMinimumSize(new java.awt.Dimension(60, 70));
        btnCodigo.setPreferredSize(new java.awt.Dimension(53, 53));
        btnCodigo.setRolloverEnabled(true);
        btnCodigo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barPrincipal.add(btnCodigo);

        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setMinimumSize(new java.awt.Dimension(100, 55));
        jSplitPane1.setName(""); // NOI18N
        jSplitPane1.setPreferredSize(new java.awt.Dimension(300, 221));

        jScrollPane1.setMinimumSize(new java.awt.Dimension(8, 500));
        jScrollPane1.setName(""); // NOI18N
        jScrollPane1.setPreferredSize(new java.awt.Dimension(182, 500));

        txtCodigo.setFont(new java.awt.Font("MS Reference Sans Serif", 0, 13)); // NOI18N
        txtCodigo.setLineWrap(true);
        txtCodigo.setTabSize(4);
        txtCodigo.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        txtCodigo.setMinimumSize(new java.awt.Dimension(2, 50));
        jScrollPane1.setViewportView(txtCodigo);

        jSplitPane1.setTopComponent(jScrollPane1);

        jScrollPane2.setMaximumSize(new java.awt.Dimension(32767, 50));
        jScrollPane2.setMinimumSize(new java.awt.Dimension(8, 50));
        jScrollPane2.setPreferredSize(new java.awt.Dimension(166, 50));

        txtMensagem.setLineWrap(true);
        jScrollPane2.setViewportView(txtMensagem);

        jSplitPane1.setRightComponent(jScrollPane2);

        mnuArquivo.setText("Arquivo");

        mnuNovo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        mnuNovo.setText("Novo");
        mnuArquivo.add(mnuNovo);

        mnuAbrir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        mnuAbrir.setText("Abrir");
        mnuArquivo.add(mnuAbrir);

        mnuGravar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK));
        mnuGravar.setText("Gravar");
        mnuArquivo.add(mnuGravar);

        mnuGravarComo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        mnuGravarComo.setText("Gravar Como");
        mnuArquivo.add(mnuGravarComo);

        mnuSair.setText("Sair");
        mnuArquivo.add(mnuSair);

        mnuAplicacao.add(mnuArquivo);

        mnuCompilador.setText("Compilador");

        mnuTabelaSimbolos.setText("Tabela de Simbolos");
        mnuCompilador.add(mnuTabelaSimbolos);

        mnuCodigo.setText("Gera Codigo");
        mnuCompilador.add(mnuCodigo);

        mnuVerificar.setText("Verificar");
        mnuVerificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuVerificarActionPerformed(evt);
            }
        });
        mnuCompilador.add(mnuVerificar);

        mnuAplicacao.add(mnuCompilador);

        setJMenuBar(mnuAplicacao);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 744, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(barPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(barPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mnuVerificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuVerificarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_mnuVerificarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {


        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                try {
                    UIManager.setLookAndFeel(new WindowsLookAndFeel());
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(TelaGrafica.class.getName()).log(Level.SEVERE, null, ex);
                }
                new TelaGrafica().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barPrincipal;
    private javax.swing.JButton btnAbrir;
    private javax.swing.JButton btnCodigo;
    private javax.swing.JButton btnGravar;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnTabelaSimbolos;
    private javax.swing.JButton btnVerificar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JMenuItem mnuAbrir;
    private javax.swing.JMenuBar mnuAplicacao;
    private javax.swing.JMenu mnuArquivo;
    private javax.swing.JMenuItem mnuCodigo;
    private javax.swing.JMenu mnuCompilador;
    private javax.swing.JMenuItem mnuGravar;
    private javax.swing.JMenuItem mnuGravarComo;
    private javax.swing.JMenuItem mnuNovo;
    private javax.swing.JMenuItem mnuSair;
    private javax.swing.JMenuItem mnuTabelaSimbolos;
    private javax.swing.JMenuItem mnuVerificar;
    private javax.swing.JTextArea txtCodigo;
    private javax.swing.JTextArea txtMensagem;
    // End of variables declaration//GEN-END:variables

    @Override
    public void packAndShow() {
        this.pack();
        this.setVisible(true);
    }

    @Override
    public void addNovoActionListener(ActionListener listener) {
        this.mnuNovo.addActionListener(listener);
        this.btnNovo.addActionListener(listener);
    }

    @Override
    public void addAbrirActionListener(ActionListener listener) {
        this.mnuAbrir.addActionListener(listener);
        this.btnAbrir.addActionListener(listener);
    }

    @Override
    public void addGravarActionListener(ActionListener listener) {
        this.mnuGravar.addActionListener(listener);
        this.btnGravar.addActionListener(listener);
    }

    @Override
    public void addGravarComoActionListener(ActionListener listener) {
        this.mnuGravarComo.addActionListener(listener);
    }

    @Override
    public void addVerificarActionListener(ActionListener listener) {
        this.mnuVerificar.addActionListener(listener);
        this.btnVerificar.addActionListener(listener);
    }

    @Override
    public void addSairActionListener(ActionListener listener) {
        this.mnuSair.addActionListener(listener);
    }

    @Override
    public String getCodigo() {
        return this.txtCodigo.getText();
    }

    @Override
    public void setCodigo(String c) {
        this.txtCodigo.setText(c);
        this.txtCodigo.repaint();
    }

    @Override
    public void setArquivo(File a) {
        this.nomeArquivo = a;
        if (a != null) {
            this.setTitle(a.getName());
        } else {
            this.setTitle("IDE");
        }
    }

    @Override
    public File getArquivo() {
        return this.nomeArquivo;
    }

    @Override
    public void setMensage(String m) {
        this.txtMensagem.setText(m);
        this.txtMensagem.repaint();
    }

    @Override
    public String getMensage() {
        return this.txtMensagem.getText();
    }

    @Override
    public void addTabelaSimboloListener(ActionListener listener) {
        this.mnuTabelaSimbolos.addActionListener(listener);
        this.btnTabelaSimbolos.addActionListener(listener);
    }

    @Override
    public void addTelaCodigoListener(ActionListener listener) {
        this.btnCodigo.addActionListener(listener);
        this.mnuCodigo.addActionListener(listener);
    }
    
   
}
